Skip to content

Fix structlog configuration fails with dict input#62286

Closed
Kabir1618 wants to merge 1 commit intoapache:mainfrom
Kabir1618:fix-structlog-dict-args-62201
Closed

Fix structlog configuration fails with dict input#62286
Kabir1618 wants to merge 1 commit intoapache:mainfrom
Kabir1618:fix-structlog-dict-args-62201

Conversation

@Kabir1618
Copy link
Copy Markdown

Summary

  • Fix KeyError when stdlib logging passes a single dict argument through structlog (e.g. logging.warning('msg %s', {'a': 10}))
  • CPython's LogRecord.__init__ unwraps single-dict args into a bare dict, but structlog's PositionalArgumentsFormatter expects a tuple and crashes when indexing it
  • Add _normalize_positional_args processor that re-wraps bare dict args back into a tuple before PositionalArgumentsFormatter processes them

Closes #62201

Test plan

  • Added 5 new tests in TestStdlibDictArgs covering: %s with dict, named %(key) formatting, empty dict, multi-key dict, and normal positional args
  • All 39 tests in test_structlog.py pass (34 existing + 5 new)
  • Manually verified the reproduction script from the issue works after the fix

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Feb 21, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@justinpakzad
Copy link
Copy Markdown
Contributor

I think there's already a PR for this issue: #62258

@Kabir1618
Copy link
Copy Markdown
Author

The other PR has failing tests.

@SakshamSinghal20
Copy link
Copy Markdown
Contributor

SakshamSinghal20 commented Feb 23, 2026

The other PR has failing tests.

@Kabir1618 That doesn't mean that the content is wrong if the maintainer has a problem with it i ll do the necessary changes.

@Kabir1618 Kabir1618 closed this Feb 23, 2026
@Kabir1618 Kabir1618 deleted the fix-structlog-dict-args-62201 branch February 23, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

structlog configuration fails with dict input

3 participants